package com.tarena.lbs.basic.web.mapper;



import com.tarena.lbs.pojo.basic.dos.AdminDO;
import com.tarena.lbs.pojo.basic.po.AdminPO;
import com.tarena.lbs.pojo.basic.query.AdminQuery;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface AdminMapper{
    @Select("SELECT id,account_type,business_id,account_phone,account_password,nickname," +
            "create_time FROM lbs_admin WHERE account_phone=#{phone}")
    AdminDO selectAdminByPhone(String phone);

    @Select("SELECT id,account_type,business_id,account_phone,account_password,nickname," +
            "create_time FROM lbs_admin WHERE id=#{id}")
    AdminDO selectAdminById(Integer adminId);



    @Select("SELECT id, account_type, business_id, account_phone, account_password, nickname, email, account_status, " +
            "create_time FROM lbs_admin WHERE 1=1")
    List<AdminDO> selectAdminByPage(AdminQuery adminQuery);

    @Select("select count(*) from lbs_admin where account_phone=#{accountPhone}")
    long selectAdminCountByPhone(String accountPhone);

    @Insert({
            "INSERT INTO lbs_admin (",
            "account_type, business_id, account_phone, ",
            "account_password, nickname, email, ",
            "account_status, create_time) ",
            "VALUES (",
            "#{accountType,jdbcType=INTEGER}, #{businessId,jdbcType=INTEGER}, #{accountPhone,jdbcType=VARCHAR}, ",
            "#{accountPassword,jdbcType=VARCHAR}, #{nickname,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, ",
            "#{accountStatus,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP})"
    })
    void insert(AdminDO adminDO);
}
